﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.ComponentModel;

#endregion


namespace ScrumTable.DL.Data.Generic.Cache
{
    /// <summary>
    /// This class represents the base interface for all tfs elements.
    /// </summary>
    public interface ICacheElement : ICacheTrackedElement, INotifyPropertyChanged, INotifyPropertyChanging, ICacheIdentity, IDisposable
    {
        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the name which is used to reference this element from other
        /// CacheElements.
        /// </summary>
        string ReferenceName { get; }

        /// <summary>
        /// Gets the top context instance.
        /// </summary>
        CacheContext OwnerContext { get; }

        /// <summary>
        /// Gets the owning project instance.
        /// </summary>
        CacheProject Project { get; }

        /// <summary>
        /// Gets/sets the parent of the current object.
        /// </summary>
        ICacheElement Parent { get; set; }

        /// <summary>
        /// Returns true if a context is avaiable and the current 
        /// instance is connected to a project.
        /// </summary>
        bool IsContextConnected { get; }

        /// <summary>
        /// Gets the unique id of the underlying back end system identity.
        /// </summary>
        string BackEndId { get; }

        /// <summary>
        /// Gets true if the changes have been synchronized with the back-end system.
        /// </summary>
        bool IsSynchronized { get; }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Assignes a new id to the current cache element. This method will
        /// throw an error, if the given id is not equal to the current and
        /// an id has already been assigned. In this case, you have to create
        /// a new CacheElement instance.
        /// </summary>
        /// <param name="id">Specifies the new id to set.</param>
        void AssignId(int id);

        /// <summary>
        /// Clones the current and all identities below the current cache element
        /// and fills them into the target store.
        /// </summary>
        /// <param name="target">Specifies the store which should be filled with the identities.</param>
        void CloneIdentities(CacheIdentityStore target);

        /// <summary>
        /// This call is performed after all changes of the element have been accepted
        /// by the back-end system and by the generic data layer.
        /// </summary>
        void ChangesAccepted();

        #endregion

        #region Events

        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}